<?php
namespace app\api\model;

use think\Model;
use think\Config;

class verticalDb extends Model
{
    private $db2 = [
        // 数据库类型
        'type'        => 'mysql',
        // 数据库连接DSN配置
        'dsn'         => '',
        'hostname'=>'',
        'database'=>'',
        'username'=>'',
        'password'=>'',
        'hostport'=>'',
        // 数据库连接参数
        'params'      => [],
        // 数据库编码默认采用utf8
        'charset'     => 'utf8',
        // 数据库表前缀
        'prefix'      => '',
    ];

    public function __construct($data = [])
    {
        $env = Config::get('dataEnv'); //1开发，2测试，3正式
        if($env ==1 ){
            //开发
            $this->db2['hostname'] = '127.0.0.1';
            $this->db2['database'] = 'vertical_db';
            $this->db2['username'] = 'root';
            $this->db2['password'] = 'root';
            $this->db2['hostport'] = '3306';
        }else if($env == 2 ){
            //测试
            $this->db2['hostname'] = 'cd-cdb-lpb2uwsk.sql.tencentcdb.com';
            $this->db2['database'] = 'vertical_db';
            $this->db2['username'] = 'root';
            $this->db2['password'] = '12345!Q@W';
            $this->db2['hostport'] = '63794';

        }else if($env == 3){
            //正式
            $this->db2['hostname'] = 'cd-cdb-csfpue3k.sql.tencentcdb.com';
            $this->db2['database'] = 'vertical_db';
            $this->db2['username'] = 'root';
            $this->db2['password'] = '12345!Q@W';
            $this->db2['hostport'] = '63509';

        }
        $this->connection = $this->db2;
    }



    protected $connection = [];

}